import os
import random
import windows.WidgetConfig
import tkinter.font as tkFont
import tkinter
import time


class Status:
    UnkownFont = "未知字体"


class Font:
    def __init__(self, win):
        self.tk = win
        self.Default = tkFont.Font(family="宋体", size=12)
        self.Text = tkFont.Font(family="华文中宋", size=12)
        self.Text_3 = tkFont.Font(family="华文中宋", size=14)
        self.Text_2 = tkFont.Font(family="华文中宋", size=15)

        self.H1 = tkFont.Font(family="幼圆", size=36, weight="bold")
        self.H2_En = tkFont.Font(family="Bodoni MT", size=20, weight="bold")
        # self.H1_WHITE = tkFont.Font(family="幼圆", size=36, weight="bold")
        self.Title = tkFont.Font(family="华文中宋", size=30)
        self.input = tkFont.Font(family="Ink Free", size=21)


class Cartoon:
    @staticmethod
    def Reg2Thread(win, TitleFrame, FormFrame):
        count = 0
        width = win.winfo_width()
        print(width)
        while count <= 600:
            TitleFrame.place(x=width / 2 - count, y=0)
            FormFrame.place(x=count, y=0)
            win.update()
            # time.sleep(0.0002)
            count += 5

        time.sleep(0.2)

    @staticmethod
    def ThreadLogin2Reg(win, TitleFrame, FormFrame):
        count = 0
        width = win.winfo_width()
        print(width)
        while count <= 600:
            TitleFrame.place(x=count, y=0)
            FormFrame.place(x=width / 2 - count, y=0)
            win.update()
            # time.sleep(0.0002)
            count += 2

        time.sleep(0.2)

    @staticmethod
    def Login2Menu(win):
        win.backLableConfig = windows.WidgetConfig.WidgetConfig(win.backcolor, tkinter.Label(win.win, fg="#000000"))
        win.backLable = win.backLableConfig.getWidget()
        y = 600
        while y >= 0:
            win.backLable.place(x=0, y=y, relwidth=1, relheight=1)
            y -= random.randint(2, 3)
            win.win.update()

    @staticmethod
    def alert_image(win, imagefile):
        return tkinter.PhotoImage(os.getcwd() + "/window_source/default.jpg")
